<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>getter,setter</title>
</head>
<body>
<script>
    const ninjaCollection = {
        ninjas: ['Yoshi','Kuma','Hattori'],
        get firstNinja(){
            console.log('getting firstNinja');
            return this.ninjas[0]
        },
        set firstNinja(value){
            console.log('set firstNinja');
            this.ninjas[0] = value
        }
    }
    // getter和setter常用于操作私有变量，而对象字面量，es6中的class，无法实现私有变量
    // 闭包可以模拟私有变量，因为在一个作用域内
</script>
</body>
</html>
